Post

Replies

Boosts

Views

Activity

WKWebView Unrecognized Selector Sent to Instance: WebAVPlayerLayer - startRedirectingVideoToLayer:forMode:
I'm using WKWebView in a Mac Catalyst app (not sure if using Catalyst makes a difference but it seems WKWebView doesn't get the "full" Mac version AppKit apps do so maybe it does). When a website has a video playing and if I click the button that I guess is a Picture in Picture button next to the "close" button the web kit process gets an unrecognized selector sent to instance exception. -[WebAVPlayerLayer startRedirectingVideoToLayer:forMode: <-- Unrecognized selector. In debugging mode at least my app doesn't crash the video continues to play and the WKWebview is unresponsive to user interaction. I have to force quit my app. -- I'm on Sonoma 14.0
1
1
652
Oct ’23
"Customize Toolbar" on NSToolbar Causes Autolayout Constraints Violation on macOS Sonoma
I have a customizable NSToolbar (using in a Mac Catalyst app "optimized for Mac"). When I right click and choose "Customize toolbar" I get the following error: Conflicting constraints detected: ( "<NSLayoutConstraint:0x6000014a24e0 NSToolbarItemGroupView:0x13de568c0.width <= 88.5 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x6000014f5f90 h=--& v=--& NSToolbarItemGroupView:0x13de568c0.width == 89 (active)>" ). Will attempt to recover by breaking <NSLayoutConstraint:0x6000014a24e0 NSToolbarItemGroupView:0x13de568c0.width <= 88.5 (active)>. Unable to simultaneously satisfy constraints: ( "<NSLayoutConstraint:0x6000014a24e0 NSToolbarItemGroupView:0x13de568c0.width <= 88.5 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x6000014f5f90 h=--& v=--& NSToolbarItemGroupView:0x13de568c0.width == 89 (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000014a24e0 NSToolbarItemGroupView:0x13de568c0.width <= 88.5 (active)> Set the NSUserDefault >NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have ->[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger.
1
0
523
Oct ’23
Mac Catalyst: Presenting view controller <UIAlertController:> from detached view controller <MyViewController:> is not supported, and may result in incorrect safe area insets and a corrupt root presentation on Sonoma
Okay so I'm getting this log every time I present a UIAlertController: Mac Catalyst: Presenting view controller <UIAlertController: 0x10f027000> from detached view controller <MyViewController: 0x10d104080> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <MyViewController: 0x10d104080> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release. A few points: MyViewController is not detached and the presentation shows just fine. I specifically check for this before presenting the alert controller like so: BOOL okayToPresentError = (self.isViewLoaded && self.view.window != nil); if (okayToPresentError) { [self presentErrorInAlertController:error]; } else { //Wait until view did appear. self.errorToPresentInViewDidAppear = error; } It spews out every time an error is fed back to my app and I present the alert controller (I can turn off the network connection and I show an alert controller with a "retry" button in it which will loop the error back so I can replay the error alert presentation over and over again) . Every time the alert controller is presented, I get this spewing in the console. Please don't start throwing hard exceptions because the check is faulty.
2
1
1.8k
Oct ’23
StoreKit Receipt Refresh Error (Mac Catalyst) Error Domain=AMSErrorDomain Code=203 "Bag Load Failed Unable to retrieve app-receipt-create because we failed to load the bag."
Been testing all day and receipt loading has been working (testing in sandbox) on Mac Catalyst. I'm using StoreKit1. All of a sudden I'm getting the following error when refreshing a receipt: ** Error Domain=AMSErrorDomain Code=203 "Bag Load Failed Unable to retrieve app-receipt-create because we failed to load the bag." UserInfo={NSDebugDescription=Bag Load Failed Unable to retrieve app-receipt-create because we failed to load the bag.** Sandbox server down?
1
0
1.6k
Oct ’23
Collection View Compositional Layout: uniformAcrossSiblingsWithEstimate Not Working
New in iOS 17 is NSCollectionLayoutDimension uniformAcrossSiblingsWithEstimate: method. I have two collection view items positioned side by side in a a grid and would like to use this feature to give them equal heights. I configure the items like so: -Each "box" in grid is made up of two vertical items -Title item configured with a fractional width of 0.5 and a estimated height. -Description item configured with a fractional width of 0.5 and a estimated height. Then the "box" wraps both the "title item" and a description item vertically NSCollectionLayoutSize *boxSize = [NSCollectionLayoutSize sizeWithFractionalWidth:0.5 estHeightUniformAcrossSiblings:estTitleHeight+estDescriptionheight]]; NSCollectionLayoutGroup *boxGroup = [NSCollectionLayoutGroup verticalGroupWithLayoutSize:boxSize subitems:@[titleItem,descriptionItem]]; //Repeat the box twice to make a side by side grid. //entireRowSize is fractional width of 1.0 and estimated height (not uniform across siblings). NSCollectionLayoutGroup *sideBySideGroup = [NSCollectionLayoutGroup horizontalGroupWithLayoutSize:entireRowSize repeatingSubitem:boxGroup count:2]; But at runtime the grids do not have equal heights. It looks exactly the same as it was on iOS 16. Am I doing something wrong? Thanks in advance.
0
0
531
Oct ’23
Mac Catalyst Modally Presented View Controllers Not Working in Xcode Live Previews
I have a UIViewController subclass I'm using in Mac Catalyst. This view controller is only ever presented as a sheet. When I try to make a live preview for it the preview is displayed a gigantic size (not the sheet's actual size at runtime). I made a separate thread about this: https://developer.apple.com/forums/thread/738641 In order to be able to preview the view controller for Mac Catalyst at the desired size I figured I'd present it on another view controller. #Preview { let wrapperVC = WrapperViewController() return wrapperVC } //In WrapperViewController override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if (firstViewDidAppear) { firstViewDidAppear = false view.backgroundColor = UIColor.yellow let realVC = ActualVCIWantToPreview() realVC.modalPresentationStyle = .formSheet present(realVC, animated: false); } } But that's not working. However if I change the device from Mac to iPad it does work so it appears modal presentations aren't working for Live Previews on Mac Catalyst (unless I'm doing something wrong but Xcode is reporting no errors it just isn't showing my presented view controller).
1
0
622
Sep ’23
Mac Catalyst with Live Previews: Any Way to Change the Size the View Controller Preview is Rendered at?
I have a Mac Catalyst app. When using "Live Previews" in Xcode 15 for a view controller of mine the live preview renders at a gigantic size in the Preview. This view controller is only ever presented as a "sheet" on Mac at a fixed size so ideally I'd like to be able to specify the "window size" for the preview environment. Is there a way to do this? Thanks in advance.
0
0
419
Sep ’23
Live Preview Not Working for UIKit Unless I raise Deployment Target to iOS 17
In Xcode 15 Live Previews are available for UIKit view controllers and views. However I noticed they do not work if the deployment target is < 17.0. If I try to make a live preview for a view controller like so: #Preview { let someVC = ViewController() return someVC } It doesn't load. The error is described below: == PREVIEW UPDATE ERROR: CompileDylibError: Failed to build ASwiftViewController.swift Compiling failed: module 'SwiftUI' has no member named 'VStack' If I raise the deployment target to iOS 17 it starts working.
3
2
2.5k
Sep ’23
UIKit Live Preview for Objective-C View Controller?
Now that live previews are available in UIKit (source: https://developer.apple.com/wwdc23/10252) I was wondering how to get a UIViewController from Objective-C. The Swift macro looks like this: #Preview { var controller = SomeViewController() return controller; } Is there a way to get a live preview for UIViewControllers/UIViews written in Objective-C (other than wrapping it as a child view controller in an empty swift view controller)?
4
0
1.2k
Sep ’23
AVSpeechSynthesizer Broken on iOS 17
I just upgraded to iOS 17 and it looks like AVSpeechSynthesizer is now broken. I noticed when feeding certain strings to AVSpeechUtterance it just dies flat out stops after only speaking a portion of the string. For example I fed it a string of approx. 1200 words and it speaks up to around 300 words or so and then just stops. The synthesizer delegate method -speechSynthesizer:didFinishSpeechUtterance: is called when this happens, as if this is supposed to be the end even though it is not even close to being finishes. Was working fine on iOS 16. FWIW I create the AVSpeechUtterance with -initWithString:
15
8
4.7k
Sep ’23
Get UICollectionLayoutSectionOrthogonalScrollingBehaviorGroupPaging like behavior for NSCollectionLayoutItems in UICollectionViewCompositionalLayout?
I have a horizontal section in my compositional layout with three items. 0 ---- 1 ----2 When scrolling toward the center I want the scrolling to snap the item at index 1 to the center of the screen. However I can't figure out how to precisely control horizontal scrolling with compositional layout (it doesn't seem possible to control the contentOffset of horizontal scrolling). When I enable paging using UICollectionLayoutSectionOrthogonalScrollingBehaviorPaging the page size assumes full device width and paging works for the item at index 0 or 2 but then the item at index 1 can never be displayed fully on screen (only one half of its width can be shown at a given time). I tried adding leading and trailing space to the group but that didn't work. When I try the UICollectionLayoutSectionOrthogonalScrollingBehaviorGroupPaging the section is displayed with the item at index 1 centered but scrolling doesn't work. I think what I'm looking for is UICollectionLayoutSectionOrthogonalScrollingBehaviorGroupPaging but at the item level or to be able to adjust the contentOffset on the scroll view at the end of dragging. Is there any way I can programmatically access the scroll view being using for horizontal scrolling? I see in the visibleItemsInvalidationHandler I'm able to get the content offset but I'm not able to change it to support snapping.
0
0
566
Aug ’23
NSLayoutConstraint 'UIView-Encapsulated-Layout-Height' on UICollectionViewListCell Breaking Self Sizing Content View Constraint
I'm using compositional layout with UICollectionView. In a particular section I configure the compositional layout to use an estimated height because I want self sizing items determined by Autolayout Constraints. Now I have a custom content configuration with autolayout constraints. At runtime I hit this log about conflicting constraints: [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) [...] <NSLayoutConstraint:0x6000024af160 UIImageView:0x120745520.height == 130 (active)> <NSLayoutConstraint:0x6000024af2a0 MyCustomContentView :0x120748d60.height >= 1.04839*UIImageView:0x120745520.height (active)> <NSLayoutConstraint:0x6000024b08c0 'UIView-Encapsulated-Layout-Height' UICollectionViewListCell:0x1214392f0.height == 44 (active)> Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000024af160 UIImageView:0x120745520.height == 130 (active)> The "UIView-Encapsulated-Layout-Height" on UICollectionViewListCell with a value of 44.0 appears to be a constraint created by the system. I'm not sure why a hard coded height of 44.0 is being used when the compositional layout is returning a section that only uses estimated heights (created via NSCollectionLayoutDimension estimatedDimension). Any ideas how I can avoid this? I'm not using custom UICollectionView cells but I am using a custom content configuration and a custom content view and setting my content configuration on a UICollectionViewListCell.
1
2
1.1k
Aug ’23
How to set NSCollectionLayoutVisibleItem's name property for use in UICollectionViewCompositionalLayout?
I'm Using UICollectionViewCompositionalLayout with a section provider and I set the NSCollectionLayoutSectionVisibleItemsInvalidationHandler on a particular section. The NSCollectionLayoutSectionVisibleItemsInvalidationHandler hands back an array of objects conforming to the NSCollectionLayoutVisibleItem protocol which has a name property which always appears to be nil. I figured there must be a way to use this name property to make it easier to do look up for the NSCollectionLayoutVisibleItem objects I'm actually looking. Is there a way to make this property nonnil? Does it get set to the UICollectionViewCell's reuse identifier or something (I'm currently using UICollectionViewCellRegistration)? Is there any documentation on the name property? https://developer.apple.com/documentation/uikit/nscollectionlayoutvisibleitem/3199122-name?language=objc
0
1
292
Jul ’23
SwiftUI Previews: Is There a Way to Have the Preview Take Over the Entire Window and Collapse the Source Code Pane?
In a SwiftUI source file Xcode displays a window with a Split View. The first split is the source code and the second split is the preview. My question is, is there a way for me to have the preview take over the entire window width (I want to collapse the source code pane and just look at the preview)? I can easily collapse the Preview pane by dragging the split to the right to collapse (but it doesn't work in reverse). I also can toggle the preview pane by going to Editor -> Canvas in the Menu bar. Currently I'm using SwiftUI just to get a live preview of UIKit view controllers so I'm not interested in looking at the SwiftUI source code, though I imagine displaying a full window preview in a separate window would be useful for SwiftUI developers too. You could edit the source code on one monitor and have the preview window on an external display. Is this not possible?
1
1
1.5k
Jul ’23
How long does WKContentRuleListStore persist compiled WKContentRuleLists?
I see WKContentRuleListStore saves compile lists by identifier. It's nice that I don't have to recompile the WKContentRuleListStore on every app launch but is there ever an event where the system discards compiled lists (other than me calling -removeContentRuleListForIdentifier:completionHandler:)? The reason I ask is should I be writing a version number with my compiled list? If I change the JSON code on an app update do I need to manually remove compiled lists after an app update before recompiling the new JSON?
0
0
441
Jul ’23